[scala-sttp4-jsoniter] extend Primitive type with UUID, LocalDate and OffsetDateTime#23801
Conversation
|
thanks for the PR cc @clasnake (2017/07), @shijinkui (2018/01), @ramzimaalej (2018/03), @chameleon82 (2020/03), @Bouillie (2020/04) @Fish86 (2023/06) |
|
@reynaldjoabet are you using this change in your production environment to confirm it works for your use cases? |
|
Is there a minimal spec to easily reproduce the issue and confirm the fix? That will help speed up the review and get it merged sooner |
Yes. Three single-parameter snippets, each one independently reproduces a failure on the current 1.
|
95ad1f8 to
03a7f9b
Compare
Extend the
Primitiveunion type inhelpers.mustachewithUUID,LocalDate, andOffsetDateTimeso that path, query, header, cookie, andform parameters typed with these formats serialize via
.toString()on thefast primitive path. Without this, fields generated from
format: uuid,format: date, andformat: date-timefall through to the Mirror-basedobject path and fail at compile time because they are not products or sums.
Add an
asStringextension method onPrimitive.A bare.toStringiscorrect for UUID and the numeric/boolean/string primitives, but produces the
wrong representation for Java's default LocalDate/
OffsetDateTime as
toStringon these does not match the expected wire format.asStringformats
OffsetDateTimewithDateTimeFormatter.ISO_OFFSET_DATE_TIMEandLocalDatewith
ISO_LOCAL_DATE, falling back to.toStringfor everything else, sodateand
date-timeparameters are emitted asISO-8601strings.@lbialy @flsh86
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Extended
Primitiveinscala-sttp4-jsoniterto includeUUID,LocalDate, andOffsetDateTime, and added ISO string formatting via a newasStringfast path across all parameter serializers. This removes the Mirror fallback and fixes compile errors in generated clients.Primitiveunion and formatting.Written for commit 03a7f9b. Summary will update on new commits.